package com.zlm.user.emp.service.impl;

import com.zlm.common.base.AbstractBaseService;
import com.zlm.common.entity.BasPostDO;
import com.zlm.common.entity.MenuTree;
import com.zlm.user.emp.dao.BasPostDao;
import com.zlm.user.emp.service.BasPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author: duyufu
 * @Date: 2019/5/16 9:37
 */
@Service
public class BasPostServiceImpl extends AbstractBaseService<BasPostDao, BasPostDO> implements BasPostService {

    @Autowired
    @Override
    public void setBaseDao(BasPostDao basPostDao) {
        this.baseDao = basPostDao;
    }

    @Override
    public List<MenuTree> getAllPostMenu(Integer category) {
        List<BasPostDO> posts = baseDao.queryAllPostMenu(category);
        List<MenuTree> list = new ArrayList<>();
        for (BasPostDO post:posts) {
            MenuTree tree = new MenuTree();
            tree.setId(post.getPostId());
            tree.setText(post.getPostName());
            tree.setLevel(post.getLevel());
            tree.setParentId(post.getParentId());
            list.add(tree);
        }
        return list;
    }

    @Override
    public List<Map<String, Object>> queryPostList(List<Integer> postList) {
        return baseDao.queryPostList(postList);
    }
}
